package com.atmc.config;

import com.atmc.entity.User;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;

/**
 * @BelongsProject: SpringCloud1216
 * @BelongsPackage: com.atmc.config
 * @Author: chuyings
 * @CreateTime: 2022-11-18  12:51
 * @Version: 1.0
 */
@Configuration
public class PubSubStream {
    @Bean
    public Supplier<String> source(){
        return ()->{
            String message="from source";
            System.out.println("===========from source============");
            return message;
        };
    }

    @Bean
    public Function<User, User> transfer(){
        return user -> {
            System.out.println("transfer: "+user);
            return user;
        };
    }

    //Consumer声明一个消息消费者，sink1就对应sink-in-0
    @Bean
    public Consumer<User> sink() {
        return user -> {
//            System.out.println("******************");
//            System.out.println("At Sink1");
//            System.out.println("******************");
            System.out.println("Received message " + user);
        };
    }
}
